def count_char(s, c):
    ret = 0
    for i in s:
        if i == c:
            ret += 1
    return ret

print(count_char("hello world", "o"))  # 应输出2
